<?php


namespace app\exception;


class BaseException extends \think\Exception
{
    public $code = 200;
    public $message = '参数错误';


    public function __construct($params=[]) {
        if (!is_array($params)) {
            return;
        }
        if (array_key_exists('code', $params)) {
            $this->code = $params['code'];
        }
        if (array_key_exists('message', $params)) {
            $this->message = $params['message'];
        }

    }


    /**
     * @param int $code
     */
    public function setCode(int $code): void
    {
        $this->code = $code;
    }


    /**
     * @param string $message
     */
    public function setMessage(string $message): void
    {
        $this->message = $message;
    }

}